//
//  BookStackController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/11/1.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "BookStackController.h"
#import "BookStackTableHeaderView.h"
#import "BookStackTableViewCell.h"
#import "BookStackCategoryController.h"



@interface BookStackController ()

@property (nonatomic, strong) BookStackTableHeaderView *headerView;

@end

@implementation BookStackController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initializes];
    
}

- (void)initializes {
    BookStackTableHeaderView *headerView = [BookStackTableHeaderView new];
    headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 300);
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    self.tableView.tableHeaderView = headerView;
    
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 200;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"BookStackTableViewCell" bundle:nil] forCellReuseIdentifier:NSStringFromClass([BookStackTableViewCell class])];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"分类" style:UIBarButtonItemStylePlain target:self action:@selector(gotoBookCategory)];
    
    [self.tableView.mj_footer setState:MJRefreshStateNoMoreData];
}

- (void)gotoBookCategory {
    [self.navigationController pushViewController:[BookStackCategoryController new] animated:YES];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    BookStackTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BookStackTableViewCell class]) forIndexPath:indexPath];
    return cell;
}


@end
